﻿using System;
using Communication.Message.Util;

namespace Communication.Message.FpgaUpdate
{
	// Token: 0x02000027 RID: 39
	public class SendHandshakeMessage : FlashUpdateChannelMessage
	{
		// Token: 0x06000147 RID: 327 RVA: 0x00003BD8 File Offset: 0x00001DD8
		public SendHandshakeMessage(byte desId, byte funCode, int totalRecTimeoutMillis, int spaceRecTimeoutMillis, int sendTimeoutMillis) : base(desId, funCode, new byte[]
		{
			98
		}, 1, 0, totalRecTimeoutMillis, spaceRecTimeoutMillis, sendTimeoutMillis)
		{
		}

		// Token: 0x06000148 RID: 328 RVA: 0x00003C04 File Offset: 0x00001E04
		public void SetPayload()
		{
			base.SetPayload(new byte[]
			{
				98
			}, 0, 1);
		}

		// Token: 0x06000149 RID: 329 RVA: 0x00003C28 File Offset: 0x00001E28
		protected override bool DealwithReceiveMsg()
		{
			if (!base.IdentifyFrame())
			{
				return false;
			}
			int num = this.receiveBuffer.ReaderIndex();
			int @ushort = (int)this.receiveBuffer.GetUshort(num + 3);
			short @short = this.receiveBuffer.GetShort(num + 5 + @ushort);
			short num2 = CrcUtil.Crc16(this.receiveBuffer.Array(), this.receiveBuffer.ReaderIndex(), 5 + @ushort, CrcType.High_Low);
			if (@short != num2)
			{
				this.SetFailure(new CrcRrrorException());
				return true;
			}
			if (@ushort == 1 && this.receiveBuffer.GetByte(num + 5) == 170)
			{
				this.errorCode = FlashUpdateErrorCode.SUCCESS;
				base.SetSuccess();
				return true;
			}
			this.errorCode = FlashUpdateErrorCode.FAILURE;
			base.SetSuccess();
			return true;
		}
	}
}
